seajs.config({
	base: "/Public/Sea/modules/",
    alias: {
    	"jquery": "jquery/1.9.1/jquery.min.js",
    	"$": 'jquery/1.9.1/jquery.min.js',
        "jquery-easing": "jquery/easing/1.3.0/easing.js",
        "validator":"validator/validator",
        "layer":"layer/layer",
        "kindeditor":"kindeditor/kindeditor", //编辑器
        "upload-image-single":"kindeditor/upload-image-single", //单图上传模块
        "upload-image-mulit":"kindeditor/upload-image-mulit", //多图片上传模块
        "colorpicker":"kindeditor/colorpicker",  //颜色选择模块
        "editormd" : "editormd/mini.mdeditor",
        "app" : "app",
        "book" : "books/book",
        "bootstrap" : "/Public/Assets/bootstrap/js/bootstrap.min.js",
        "jstree" : "jstree/jstree.min.js"
    },
});

var miniappC = {
	base:"/Public/Sea/customs/",
	run:function(configs){
		for(var i = 0; i < configs.length ; i++){
			seajs.use(this.base+configs[i],function(init){
				init.run();
			});
		}
	}
};
//default
var miniappD = {
	base: "/Public/Sea/modules/",
	run:function(configs){
		for(var i = 0; i < configs.length ; i++){
			seajs.use(this.base+configs[i],function(init){
				init.run();
			});
		}
	}
};






window.initpage = function(dom,json){
	
	var url = json.pageurl+'?';
	
	var p = json.p;
	
	var cur = parseInt(json.cur);
	var itemcount = 5;
	var html = '<nav style="text-align:center;">'+
					'<ul class="pagination">';
	var total = parseInt(json.total);
	if(total==0) total = 1;
	var pagesize = Math.ceil(total / parseInt(json.size)) ; //小数点进位

	var mo = parseInt(cur/(itemcount+1));
	var tt ;
	if(cur != 1){
		html += '<li><a href="'+url+p+'='+1+'">第一页</a></li>';
	}
	if(mo > 0){
		tt = (mo-1)*itemcount + 1;
		html += '<li><a href="'+url+p+'='+tt+'">«上'+itemcount+'页</a></li>';
	}
	if(cur > 1){
		html += '<li class="prev"><a href="'+url+p+'='+(cur-1)+'">«上一页</a></li>';
	}
	
	for(var i=1 ;i<= itemcount ;i++){
		if(i <= (pagesize-itemcount*mo)){
			var item = '';
			var param = mo*(itemcount)+i;
			if(param == cur){
				item = '<li class="active"><a href="javascript:;">'+param+'</a></li>';
			}else{
				item = '<li><a href="'+url+p+'='+param+'">'+param+'</a></li>';
			}
			html += item;
		}else{
			break;
		}
		
	}
	
	if(cur < pagesize){
		html += '<li class="next"><a href="'+url+p+'='+(cur+1)+'">下一页»</a></li>';
	}
	if(pagesize/itemcount > (mo+1)){
		tt = (mo+1)*itemcount + 1;
		html += '<li class="prev"><a href="'+url+p+'='+tt+'">下'+itemcount+'页»</a></li>';
	}
	if(cur != pagesize){
		html += '<li><a href="'+url+p+'='+pagesize+'">最后一页</a></li>';
	}
	
	html += '</ul>'+
		'</nav>';
	
	$(dom).html(html);

}